<?php
namespace backend\controllers;

use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use yii\web\Response;

/**
 * Site controller
 */
class TousuController extends Controller
{
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'actions' => ['login', 'error'],
                        'allow' => true,
                    ],
                    [
                        'actions' => ['logout', 'index','showmap','test','gettdt'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'logout' => ['post'],
                ],
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
        ];
    }

    /**
     *  在投诉页面中显示iframe框架
     */
    public function actionIndex()
    {
        return $this->renderPartial('index');
    }

    /*
     *  返回ajax数据案例（暂时没用）
     */
    public function actionTest(){
        Yii::$app->response->format=Response::FORMAT_JSON;
        return kml_to_json('http://localhost/gtl/2.xml');
    }

    /*
     *  获取投诉数据
     */
    public function actionGettdt(){
        $url = Yii::$app->request->get('url');
        return file_get_contents($url);
    }

}
